////////////////////////////////////////////////////////////////////////////////
// Filename: rectangle.cpp
////////////////////////////////////////////////////////////////////////////////
#include "rectangle.hpp"

miv::Rectangle::Rectangle() : miv::Polygon() {
	m_position = NULL;
}

miv::Rectangle::~Rectangle() {

}

bool miv::Rectangle::Initialize(unsigned int width, unsigned int height, Vector2D* position, D3DXVECTOR4 color, ID3D11Device* device) {
	Vector2D** vertices = new Vector2D*[4];
	unsigned long* indices = new unsigned long[6];
	indices[0] = 0;
	indices[1] = 1;
	indices[2] = 2;
	indices[3] = 0;
	indices[4] = 2;
	indices[5] = 3;
	m_width = width;
	m_height = height;
	m_position = position;

	vertices[0] = new Vector2D(m_position->GetX() - m_width / 2, m_position->GetY() - m_height / 2);
	vertices[1] = new Vector2D(m_position->GetX() - m_width / 2, m_position->GetY() + m_height / 2);
	vertices[2] = new Vector2D(m_position->GetX() + m_width / 2, m_position->GetY() + m_height / 2);
	vertices[3] = new Vector2D(m_position->GetX() + m_width / 2, m_position->GetY() - m_height / 2);

	miv::Polygon::Initialize(vertices, indices, 4, 6,color, device);

	delete[] vertices;
	delete[] indices;

	return true;
}

void miv::Rectangle::Shutdown() {
	m_position = NULL;

	miv::Polygon::Shutdown();
}
